//
//  UpLoadImageApi.m
//  SeaMelonSeeds_Counselor
//
//  Created by 杨笑 on 2017/9/14.
//  Copyright © 2017年 杨笑. All rights reserved.
//

#import "UpLoadImageApi.h"
#import <AFNetworking.h>

@implementation UpLoadImageApi
{
    UIImage *_image;
}
-(id)initWithImage:(UIImage *)img{
    self = [super init];
    if (self) {
        _image = img;
    }
    return self;
}

-(NSString *)requestUrl{
    return @"counselor/uploadImage";
}
-(YTKRequestMethod)requestMethod{
    return  YTKRequestMethodPOST;
}

-(AFConstructingBlock)constructingBodyBlock{
    return ^(id<AFMultipartFormData> formData) {
        NSData *data = UIImageJPEGRepresentation(_image, 0.5);
        NSString *name = @"image";
        NSString *formKey = @"image";
        NSString *type = @"image/jpeg";
        [formData appendPartWithFileData:data name:formKey fileName:name mimeType:type];
    };
}

@end
